local shisha = fk.CreateSkill {
  name = "th_shisha",
}

local U = require "packages/utility/utility"

shisha:addEffect(fk.Death, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target ~= player and player:hasSkill(shisha.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local draw = "draw3"
    local obtain = "#th_shisha-all:" .. target.id
    local choices = {draw}
    local cards_id = target:getCardIds{Player.Hand, Player.Equip}
    if #cards_id > 0 then
      table.insert(choices, obtain)
    end
    local choice = room:askToChoice(player, {
      choices = choices,
      skill_name = shisha.name
    })
    if choice == obtain then
      room:obtainCard(player, cards_id, false, fk.ReasonPrey)
    else
      cards_id = player:drawCards(3, shisha.name)
    end
    for _, cid in ipairs(cards_id) do
      room:setCardMark(Fk:getCardById(cid), "@@th_shisha-inhand", player.id)
    end
  end,
})
shisha:addEffect("maxcards", {
  name = "#th_shisha_maxcard",
  exclude_from = function(self, player, card)
    return card and player and card:getMark("@@th_shisha-inhand") == player.id
  end
})

Fk:loadTranslationTable{
  ["th_shisha"] = "噬沙",
  [":th_shisha"] = "其他角色死亡时，你可以获得其所有牌或摸三张牌，这些牌不计入你的手牌上限。",

  ["#th_shisha-all"] = "获得%src的所有牌",

  ["@@th_shisha-inhand"] = "噬沙",
}

return shisha